import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login,
    meta: { name: '登录', path: '/', },
  },
  {
    path: '/content',
    name: 'Content',
    redirect: '/index',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Content.vue'),
    children: [
      {
        path: '/index',
        name: 'Index',
        component: () => import('../views/Index.vue'),
        meta: { name: '首页', path: '/index', },
      },
      {
        path: '/config',
        name: 'Config',
        component: () => import('../views/Config.vue'),
        meta: { name: '配置', path: '/config', },
      },
      {
        path: '/shoping',
        name: 'Shoping',
        component: () => import('../views/Shoping.vue'),
        meta: { name: '商城', path: '/shoping', },
      },
      {
        path: '/error',
        name: 'Error',
        component: () => import('../views/Error.vue'),
        meta: { name: '错误页', path: '/error', },
      },
      {
        path: '/upload',
        name: 'Upload',
        component: () => import('../views/Upload.vue'),
        meta: { name: '上传图片', path: '/upload', },
      }
    ]
  },
]

const router = new VueRouter({
  routes
})



//解决element ui 的导航菜单里的 重复点击选项  路有报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router
